package com.springboot.study.tests.java8;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

/**
 * @Author: guodong
 * @Date: 2020/9/1 13:27
 * @Version: 1.0
 * @Description:
 */
public class Java8Consumer1 {


//    public static void main(String[] args) {
//        Consumer<String> stringConsumer = x -> System.out.println("hello!" + x);
//        stringConsumer.accept("cattle");
//    }


    /**-----------------------------------------------------------------**/

//    public static void main(String[] args) {
//        List<Integer> integers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8);
//        Consumer<Integer> integerConsumer = x -> System.out.println(x);
//        forEach(integers, integerConsumer);
//        System.out.println("===========");
//        forEach(integers, x -> System.out.println(x));
//    }
//
//    static <T> void forEach(List<T> list, Consumer<T> consumer) {
//        list.forEach(consumer);
//    }



    /**-----------------------------------------------------------------**/


    public static void main(String[] args) {
        // 对象：：实例方法名
        Consumer<String> con1 = x -> System.out.println(x);
        con1.accept("abc");
        Consumer<String> con = System.out::println;
        con.accept("abc");
    }



}
